package com.taocore.top.title.service;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.taocore.top.title.domain.DiagnoseResult;

public class ComparationChecker implements TitleChecker{

	@Override
	public DiagnoseResult check(String title) {
		String msg = "标题中带有“非”、“仿”、“PK”， “超越”，“比**更**”等词，出现与其他产品或品牌比较的情况，会影响得分。";
		final String[] words = {"非", "仿", "PK", "超越"};
		for (String w : words)
		{
			if (title.contains(w))
			{
				DiagnoseResult result = new DiagnoseResult();
				result.setMsg(msg);
				return result;
			}
		}
		Pattern pattern = Pattern.compile(".*比.*更.*");
		Matcher matcher = pattern.matcher(title);
		if (matcher.matches())
		{
			DiagnoseResult result = new DiagnoseResult();
			result.setMsg(msg);
			return result;
		}
		return null;
	}

}
